package com.abctime.demo;

import android.content.Context;
import android.net.Uri;
import android.widget.ImageView;

import com.abctime.lib.imageloader.BaseImageLoaderStrategy;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;

//---Glide 4.x.x
//import com.bumptech.glide.request.RequestOptions;

public class GlideImageLoaderStrategy implements BaseImageLoaderStrategy {

    @Override
    public void loadImage(Context context, String url, int placeholder, ImageView imageView) {

        //---Glide 3.8.0

        Glide.with(context)
                .load(url)
                .diskCacheStrategy(DiskCacheStrategy.RESULT)
                .placeholder(placeholder)
                .into(imageView);

        //---Glide 4.x.x

//        Glide.with(context)
//                .asDrawable()
//                .load(url)
//                .apply(new RequestOptions().placeholder(placeholder)
//                        .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
//                ).into(imageView);

    }

    @Override
    public void loadLocalImage(Context context, Uri uri, int placeholder, ImageView imageView) {

        //---Glide 3.8.0

        Glide.with(context)
                .load(uri)
                .diskCacheStrategy(DiskCacheStrategy.RESULT)
                .placeholder(placeholder)
                .into(imageView);

        //---Glide 4.x.x

//        Glide.with(context)
//                .asDrawable()
//                .load(uri)
//                .apply(new RequestOptions().placeholder(placeholder)
//                        .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
//                ).into(imageView);

    }

}
